﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.XHRS
{
    class Class6
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {


            if (ppa.Period == 0)
            {
                if (ppa.SchemePeriodActing.HolderStates.Contains("身故") || ppa.SchemePeriodActing.HolderStates.Contains("全残"))
                {
                    da.Value = ppa.TotalFee * 1.2;
                    ppa.IsCurrentFinish = true;
                }
            }else if (ppa.Age <25)
            {
                bool state = false;

                for (int i = 0; i <= ppa.Period; i++)
                {
                    IPolicyPeriodActing ppa2 = ppa.PolicyActing.PeriodActings[i];

                    if (ppa2.SchemePeriodActing.HolderStates.Contains("身故") || ppa2.SchemePeriodActing.HolderStates.Contains("全残"))
                    {
                        state = true;
                        break;
                    }
                }

                if (state)
                {
                    if (ppa.Age >= 0 && ppa.Age <= 11)
                    {
                        da.Value = ppa.Amount * 0.1;
                    }
                    else if (ppa.Age >= 12 && ppa.Age <= 17)
                    {
                        da.Value = ppa.Amount * 0.2;
                    }
                    else if (ppa.Age >= 18 && ppa.Age <= 23)
                    {
                        da.Value = ppa.Amount * 0.3;
                    }
                    else if (ppa.Age == 24)
                    {
                        da.Value = ppa.Amount;
                        ppa.IsCurrentFinish = true;
                    }
                }
            }
            else if (ppa.Age >= 25)
            {
                if (ppa.SchemePeriodActing.HolderStates.Contains("身故") || ppa.SchemePeriodActing.HolderStates.Contains("全残"))
                {
                    da.Value = ppa.Amount;
                    ppa.IsCurrentFinish = true;
                }
            }


            





        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {

            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                da.Value = ppa.Amount;
                ppa.IsCurrentFinish = true;
            }


        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {

            if (ppa.SchemePeriodActing.HolderStates.Contains("身故") || ppa.SchemePeriodActing.HolderStates.Contains("全残"))
            {
                if (ppa.Period > 0)
                {
                    ppa.Fee = 0;
                }
            }


        }
    }
}
